import http from '../util/http.js';

export default {
    // 通用API请求
    uploadAvatar:(data)=> {
        return http({
            url: 'api/file/avatar',
            method: 'post',
            data,
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    },

    getCaptcha:()=> {
        return http({
            method: "get",
            url: "api/captcha/line"
        });
    },
    login:(obj)=>{
        const captchakey=sessionStorage.getItem("captchaKey");
        obj.captchakey=captchakey;
        return http({
            method:'post',
            params:obj,
            url:'api/user/login',
        })
    },

    getChartsA:()=>{
        return http({
            method:"get",
            url:"api/charts/chartsA"
        });
    },
    getUserList:()=>{
        return http({
            method:"get",
            url:"api/user/list"
        })
    },
    getUserPage:(page)=>{
        return http({
            method:"get",
            url:"api/user/page",
            params:page
        });
    },

    deleteUser: (uid) => {
        return http({
            method: "delete",
            url: "api/user/delete/" + uid
        });
    },
    addUser:(obj)=>{
        return http({
            method:"post",
            url:"api/user/add",
            data:obj,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    },
    editUser:(obj)=>{
        return http({
            method:"put",
            url:"api/user/update",
            data:obj,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    },
}